home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Demos / A.D. Software / OOFILE / Buildable, limited OOFILE / samples / ooftst09.cpp < prev    next >
C/C++ Source or Header  |  1996-02-14  |  1KB  |  50 lines

  1. // Copyright 1994 A.D. Software. All Rights Reserved
  2.  
  3. // OOFTEST9
  4.  
  5. // this sample deletes records including related data
  6.  
  7. // Simple stream I/O is used to interact with the user.
  8. #include "oofile.hpp"
  9.  
  10.  
  11. #include "ooftst02.inc"
  12.  
  13.  
  14. int main()
  15. {
  16.     cout << "OOFILE Validation Suite - Test 9\n"
  17.          << "Simple test to demonstrate deleting records" << endl
  18.          << "using the database from ooftst02" << endl;
  19.          
  20.     if (dbConnect::fileExists("ooftst09.db"))
  21.         theDB.openConnection("ooftst09.db");
  22.     else {
  23.         theDB.newConnection("ooftst09.db");
  24.     }
  25.     Patients.AddTestData();  // always add data - file is empty from last run if it exists
  26.  
  27.     cout << "Entire database before deletions" << endl << theDB << endl;
  28.  
  29.     dbView smithVisits(Patients.Visits); 
  30.     smithVisits << Patients.Visits->VisitDate << Patients.Visits->Why; 
  31.  
  32.     Patients.search(Patients.LastName=="Smith");
  33.     cout << "Dumping Smith and his visits: " << endl 
  34.          << Patients << endl 
  35.          << smithVisits << endl;
  36.         
  37.     cout << "Deleting Smith" << endl;
  38.     Patients.deleteRecord();
  39.  
  40.     cout << "Entire database without Smith" << endl << theDB << endl;
  41.     
  42.     cout << "Deleting all remaining records" << endl;
  43.     Patients.deleteAll();
  44.  
  45.     cout << "Entire database  - should be empty" << endl << theDB << endl;
  46.     
  47.     cout << "done" << endl;
  48.  
  49.     return EXIT_SUCCESS;
  50. }